# Generated Cmake Pico project file

cmake_minimum_required(VERSION 3.13)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

# Initialise pico_sdk from installed location
# (note this can come from environment, CMake cache etc)
set(PICO_SDK_PATH "/home/pi/rp2040/pico/pico-sdk")

set(PICO_BOARD pico CACHE STRING "Board type")

# Pull in Raspberry Pi Pico SDK (must be before project)
include(pico_sdk_import.cmake)

if (PICO_SDK_VERSION_STRING VERSION_LESS "1.4.0")
  message(FATAL_ERROR "Raspberry Pi Pico SDK version 1.4.0 (or later) required. Your version is ${PICO_SDK_VERSION_STRING}")
endif()

project(uf2-nand-flash-prog C CXX ASM)

# Initialise the Raspberry Pi Pico SDK
pico_sdk_init()

# Add executable. Default name is the project name, version 0.1

add_executable(uf2-nand-flash-prog)

target_sources(uf2-nand-flash-prog PUBLIC
        ${CMAKE_CURRENT_LIST_DIR}/main.c
        ${CMAKE_CURRENT_LIST_DIR}/usb_descriptors.c
        ${CMAKE_CURRENT_LIST_DIR}/msc_disk_dual.c
        ${CMAKE_CURRENT_LIST_DIR}/spi_flash.c
        ${CMAKE_CURRENT_LIST_DIR}/pwm_led_fade.c
        )

pico_set_program_name(uf2-nand-flash-prog "uf2-nand-flash-prog")
pico_set_program_version(uf2-nand-flash-prog "0.1")

pico_enable_stdio_uart(uf2-nand-flash-prog 1)
pico_enable_stdio_usb(uf2-nand-flash-prog 0)

# In addition to pico_stdlib required for common PicoSDK functionality, add dependency on tinyusb_device
# for TinyUSB device support and tinyusb_board for the additional board support library used by the example
target_link_libraries(uf2-nand-flash-prog PUBLIC pico_stdlib pico_unique_id tinyusb_device tinyusb_board hardware_spi hardware_pwm)

# Uncomment this line to enable fix for Errata RP2040-E5 (the fix requires use of GPIO 15)
#target_compile_definitions(uf2-nand-flash-prog PUBLIC PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1)


# Add the standard include files to the build
target_include_directories(uf2-nand-flash-prog PRIVATE
  ${CMAKE_CURRENT_LIST_DIR}
  ${CMAKE_CURRENT_LIST_DIR}/.. # for our common lwipopts or any other standard includes, if required
)

pico_add_extra_outputs(uf2-nand-flash-prog)

